<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>更改边框颜色</title>
<script>
  var sye = "";
  function red(event) {
    sye = event.target.style.border;
    event.target.style.border = "1px solid red";
  }
  function black(event) {
    event.target.style.border = sye;
  }
</script>
</head>
<body>
  <label>
    点击文本框输入字符
    <input type="text" onfocus="red(event)" onblur="black(event)">
  </label>
  <br>
  获得文本框的焦点后，边框颜色更改为红色
  <br>
  失去文本框的焦点后，边框颜色还原
</body>
</html>